package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class Details {
    private int detId;//详情id
    private Timestamp detTime;//创建时间
    private Integer detNum;//数量
    private BigDecimal detTotal;//小计
    private String detDiscount;//折扣
    private BusinessInfo businessInfoByBusinesId;//商机
    private Integer prsId;//外键
    private BigDecimal detPrice;//售价
    private BigDecimal detDiscountedPrice;//折后价
    private BigDecimal detFactoryrice;//进价

    public Details(int detId, Integer detNum, BigDecimal detTotal, String detDiscount, BusinessInfo businessInfoByBusinesId, Integer prsId, BigDecimal detPrice, BigDecimal detDiscountedPrice, BigDecimal detFactoryrice) {
        this.detId = detId;
        this.detNum = detNum;
        this.detTotal = detTotal;
        this.detDiscount = detDiscount;
        this.businessInfoByBusinesId = businessInfoByBusinesId;
        this.prsId = prsId;
        this.detPrice = detPrice;
        this.detDiscountedPrice = detDiscountedPrice;
        this.detFactoryrice = detFactoryrice;
    }

    public Details() {
    }

    @Id
    @Column(name = "det_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getDetId() {
        return detId;
    }

    public void setDetId(int detId) {
        this.detId = detId;
    }

    @Basic
    @Column(name = "det_time")
    public Timestamp getDetTime() {
        return detTime;
    }

    public void setDetTime(Timestamp detTime) {
        this.detTime = detTime;
    }

    @Basic
    @Column(name = "det_num")
    public Integer getDetNum() {
        return detNum;
    }

    public void setDetNum(Integer detNum) {
        this.detNum = detNum;
    }

    @Basic
    @Column(name = "det_total")
    public BigDecimal getDetTotal() {
        return detTotal;
    }

    public void setDetTotal(BigDecimal detTotal) {
        this.detTotal = detTotal;
    }

    @Basic
    @Column(name = "det_discount")
    public String getDetDiscount() {
        return detDiscount;
    }

    public void setDetDiscount(String detDiscount) {
        this.detDiscount = detDiscount;
    }

    @Basic
    @Column(name = "prs_id")
    public Integer getPrsId() {
        return prsId;
    }

    public void setPrsId(Integer prsId) {
        this.prsId = prsId;
    }

    @Basic
    @Column(name = "det_price")
    public BigDecimal getDetPrice() {
        return detPrice;
    }


    public void setDetPrice(BigDecimal detPrice) {
        this.detPrice = detPrice;
    }

    @Basic
    @Column(name = "det_discounted_price")
    public BigDecimal getDetDiscountedPrice() {
        return detDiscountedPrice;
    }

    public void setDetDiscountedPrice(BigDecimal detDiscountedPrice) {
        this.detDiscountedPrice = detDiscountedPrice;
    }

    @Basic
    @Column(name = "det_factory_price")
    public BigDecimal getDetFactoryrice() {
        return detFactoryrice;
    }

    public void setDetFactoryrice(BigDecimal detFactoryrice) {
        this.detFactoryrice = detFactoryrice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Details details = (Details) o;
        return detId == details.detId &&
                Objects.equals(detTime, details.detTime) &&
                Objects.equals(detNum, details.detNum) &&
                Objects.equals(detTotal, details.detTotal) &&
                Objects.equals(detDiscount, details.detDiscount);
    }

    @Override
    public int hashCode() {
        return Objects.hash(detId, detTime, detNum, detTotal, detDiscount);
    }

    @ManyToOne
    @JoinColumn(name = "busines_id", referencedColumnName = "busines_id")
    public BusinessInfo getBusinessInfoByBusinesId() {
        return businessInfoByBusinesId;
    }

    public void setBusinessInfoByBusinesId(BusinessInfo businessInfoByBusinesId) {
        this.businessInfoByBusinesId = businessInfoByBusinesId;
    }

    @Override
    public String toString() {
        return "Details{" +
                "detId=" + detId +
                ", detNum=" + detNum +
                ", detTotal=" + detTotal +
                ", detDiscount=" + detDiscount +
                '}';
    }
}
